package BehavioralMode.mediator.MarriageIntermediary;

import java.util.LinkedList;
import java.util.List;

public class SpecificMediator implements Mediator{
    List<Person> personList = new LinkedList<>();

    @Override
    public void register(Person person) {
          personList.add(person);
    }

    @Override
    public void matching(Person person) {

         List<Person> partnerList = new LinkedList<>();
         for (Person person1 : personList){
             if(person.getGender() == person1.getGender()) continue;
             if(person1.getAge() > person.getPartnerMaxAge()) continue;
             if(person1.getAge() < person.getPartnerMaxAge()) continue;
             partnerList.add(person1);
         }

         System.out.println("打印" +person.getName() + "的伴侣");
         for (Person person2 : partnerList){
            System.out.println(person2);
         }

    }
}
